/* author: Mariana Horita
   mariana.horita@gmail.com
   file: A2E3.cs*/


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Resolucao
{
    public partial class A2E3 : Form
    {
        private int value;
        private char op;

        public A2E3()
        {
            InitializeComponent();
        }

        private void btNum_Click(object sender, EventArgs e)
        {
            txtTela.Text += ((Button)sender).Text;
        }

        private void btClear_Click(object sender, EventArgs e)
        {
            value = 0;
            txtTela.Clear();
        }

        private void btMenos_Click(object sender, EventArgs e)
        {
            op = '-';
            value = Convert.ToInt32(txtTela.Text);
            txtTela.Clear();
        }

        private void btMais_Click(object sender, EventArgs e)
        {
            op = '+';
            value = Convert.ToInt32(txtTela.Text);
            txtTela.Clear();
        }

        private void btIgual_Click(object sender, EventArgs e)
        {
            int currentValue = op == '-' ? Convert.ToInt32(txtTela.Text) * -1 : Convert.ToInt32(txtTela.Text);
            
            txtTela.Text = (value + currentValue).ToString();

            value = Convert.ToInt32(txtTela.Text);
        }
    }
}
